using System;

namespace Utilities.LinkedList
{
    public class LinkedListUtility
    {
        public static ListNode Create(int[] data)
        {
            var head = new ListNode();
            var p = head;
            for (int i = 0; i < data.Length; i++)
            {
                p.val = data[i];
                p.next = new ListNode();
                if (i < data.Length - 1)
                {
                    p = p.next;
                }
            }

            return head;
        }

        public static void Print(ListNode head)
        {
            var p = head;
            while (p != null)
            {
                Console.Write($"{p.val} ");
                p = p.next;
            }
        }
    }
}